package main

import (
	"log"
	"net/http"

	"gitee.com/zhaokangming/tiny-ticktok/config"
	"gitee.com/zhaokangming/tiny-ticktok/controller"
	"gitee.com/zhaokangming/tiny-ticktok/dao"
	"gitee.com/zhaokangming/tiny-ticktok/pkg/logx"

	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

func main() {
	config.Init()
	logx.InitLogger()
	dao.Init()
	defer zap.L().Sync()
	defer dao.RDB.Close()
	gin.SetMode(config.TikTok.RunMode)
	r := gin.Default()
	controller.InitRouter(r)
	s := &http.Server{
		Addr:           ":" + config.TikTok.HTTPPort,
		Handler:        r,
		ReadTimeout:    config.TikTok.ReadTimeout,  //允许读取的最大时间
		WriteTimeout:   config.TikTok.WriteTimeout, //允许写入的最大时间
		MaxHeaderBytes: 1 << 20,                    //允许请求头的最大字节数
	}
	log.Fatal(s.ListenAndServe())
}
